﻿CREATE FUNCTION [dbo].[fnGetLastETLTime]
(

)
RETURNS DATETIME
AS
BEGIN

	DECLARE @LastELTTime DATETIME;

	Set @LastELTTime = 
		(SELECT TOP 1 [EndDateTime]   
			FROM [dbo].[ApplicationExecutionInstance]
			ORDER BY [EndDateTime] DESC)

	IF (@LastELTTime is null)
		set @LastELTTime = '1900-01-01'

	RETURN @LastELTTime

END